<script>
  function random_number(lower_bound,upper_bound)
  {
    var initial_random=(upper_bound-lower_bound+1)*Math.random()+lower_bound;
    return Math.floor(initial_random);
  }

  var result=new Array();
  for(var i=1;i<=6;i++)
  {
    result[i]=0;
  }

  var lower=1;
  var upper=6;
  var total=100000;
  for(var i=1;i<total;i++)
  {
    this_voll=random_number(lower,upper);
    result[this_voll]+=1;
  }

  document.write("The average is "+total/6+"<br>");
  for(var i=1;i<=6;i++)
    document.write(i+" ="+result[i]+"<br>")
</script>
